package com.joysuch.wwyt.bp.entity.contractor;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.joysuch.wwyt.core.support.AutoSetCommonFieldListener;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import java.time.LocalDate;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * @Author ZhangDong
 * @Date 2020/7/8 15:59
 */
@EntityListeners({AuditingEntityListener.class, AutoSetCommonFieldListener.class})
@Entity
@Table(name = "wwyt_bp_contractor_cert")
@SQLDelete(sql = "update wwyt_bp_contractor_cert set DELETE_FLAG = '1' where id= ?")
@SQLDeleteAll(sql = "update wwyt_bp_contractor_cert set DELETE_FLAG = '1' where id= ?")
@Where(clause = "DELETE_FLAG = '0'")
@Data
public class BpContractorCert {

    @Id
    @GeneratedValue(strategy = IDENTITY)
    private Long id;
    @ApiModelProperty("承包商表Id")
    private Long contractorId;
    @ApiModelProperty("承包商资质证书编号")
    private String code;
    @ApiModelProperty("承包商资质证书名称")
    @NotBlank(message = "证书名称不能为空")
    private String certName;
    @ApiModelProperty("资质证书到期日期")
    private LocalDate certExpireDate;
    @ApiModelProperty("证书文件json")
    private String attachmentJson;
    @ApiModelProperty("证书到期是否已提醒: 0 否; 1 是")
    private Integer dutyScriptRemindOrNot = 0;


    //通用字段
    @ApiModelProperty("数据状态字段: 0 无效; 1 有效")
    private Integer state;
    @ApiModelProperty("创建人")
    @org.springframework.data.annotation.CreatedBy
    @JsonIgnore
    private Long createBy;
    @ApiModelProperty("创建时间")
    @org.springframework.data.annotation.CreatedDate
    @JsonIgnore
    private java.time.LocalDateTime createTime;
    @ApiModelProperty("更新人")
    @org.springframework.data.annotation.LastModifiedBy
    @JsonIgnore
    private Long updateBy;
    @ApiModelProperty("更新时间")
    @org.springframework.data.annotation.LastModifiedDate
    @JsonIgnore
    private java.time.LocalDateTime updateTime;
    @ApiModelProperty("租户")
    @JsonIgnore
    private Long tenentId;
    @ApiModelProperty("组织机构代码")
    @JsonIgnore
    private String orgCode;
    @ApiModelProperty("删除标记")
    @JsonIgnore
    private String deleteFlag;
}
